<template>
	<view class="container">
		<view class="header"></view>
		<view class="u-flex u-row-center" v-if="list.length == 0" style="flex-direction: column;">
			<image style="width:300rpx;height:300rpx;margin-top:150rpx;" mode="widthFix" src="../../../static/img/no.png"></image>
			<text style="color:#ccc">暂无数据</text>
		</view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="item-header" @click="handleClickItem(item)">
					<view class="left">
						<image :src="itemTitle"></image>
						<view class="title">{{item.name}}</view>
					</view>
					<view class="right">
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="content">
					<view class="item-cell">
						<view class="left">
							<image :src="itemAmount"></image>
							<view class="title">合同金额</view>
						</view>
						<view class="right">
							<view class="text amount" v-if="item.demand != undefined">{{item.demand.sjfy}}</view>
						</view>
					</view>
					<view class="item-cell">
						<view class="left">
							<image :src="itemLocation"></image>
							<view class="title">项目地点</view>
						</view>
						<view class="right">
							<view class="text">{{item.place}}</view>
						</view>
					</view>
					<view class="item-cell">
						<view class="left">
							<image :src="itemJF"></image>
							<view class="title">甲方</view>
						</view>
						<view class="right">
							<view class="text"></view>
						</view>
					</view>
					<view class="item-cell">
						<view class="left">
							<image :src="itemYF"></image>
							<view class="title">乙方</view>
						</view>
						<view class="right">
							<view class="text"></view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore class="u-m-t-40" v-if="list.length > 2" :status="loadStatus" bgColor="#f4f4f4"></u-loadmore>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemAmount: this.$mAssetsPath.itemAmount,
				itemJF: this.$mAssetsPath.itemJF,
				itemYF: this.$mAssetsPath.itemYF,
				itemTitle: this.$mAssetsPath.itemTitle,
				itemLocation: this.$mAssetsPath.itemLocation,
				form:{
					pageNum:1,
					pageSize:10
				},
				loadStatus: 'loadmore',
				list:[]
			}
		},
		onLoad() {
			this.getList();
		},
		onPullDownRefresh: function() {
			this.form.pageNum = 1;
			this.getList();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom:function(e){
			// 此tab为空数据
			this.form.pageNum += 1;
			this.loadStatus= "loading";
			this.getList(this.form.pageNum);
			setTimeout(() => {
				this.loadStatus="loadmore";
			}, 1000);
		},
		methods: {
			handleClickItem(item){
				this.$mRouter.push({
					route:this.$mRoutesConfig.throughTrainDetail,
					query:{
						data:encodeURIComponent(JSON.stringify(item))
					}
				})
			},
			async getList(page){
				let data = await this.$apis.findProjectAll(this.form);
				if(page){
					this.list = this.list.concat(data.data.content);
					if(data.data.last){
						this.loadStatus="nomore";
					}
				}else{
					this.list= data.data.content;
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	page,.container {
		background-color: #f4f4f4;
	}

	.container {
		overflow: hidden;
		.list {
			width: 100%;
			padding: 0 20upx;
			position: relative;
			z-index: 1;
			margin-top: 48upx;

			.item {
				margin-bottom: 20upx;
				height: 354upx;
				background-color: #fff;
				border-radius: 20upx;

				.content {
					flex: 1;
					justify-content: space-between;
					display: flex;
					flex-direction: column;
					padding: 10upx 0;

					.item-cell {
						height: 65upx;
						display: flex;
						align-items: center;
						justify-content: space-between;
						padding: 0 0 0 22upx;

						.right {
							.text {
								color: #888D99;
								padding-right: 20upx;
							}

							.amount {
								background-color: #FF8F28;
								color: #fff;
								padding: 0 20upx;
								border-radius: 23px 0px 0px 23px;
							}
						}

						.left {
							height: 30upx;
							display: flex;

							.title {
								font-size: 30upx;
								line-height: 30upx;
								margin-left: 30upx;
								color: #4B9CFF;
							}

							image {
								width: 30upx;
								height: 30upx;
							}
						}
					}
				}

				.item-header {
					height: 73upx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 0 22upx;
					border-bottom: #DADFED solid 1upx;

					.left {
						height: 30upx;
						display: flex;

						.title {
							font-size: 30upx;
							line-height: 30upx;
							margin-left: 30upx;
						}

						image {
							width: 30upx;
							height: 30upx;
						}
					}
				}

			}
		}

		.header {
			background-color: #AB61FF;
			width: 100%;
			height: 145upx;
			position: absolute;
		}
	}
</style>
